package cn.yunhe.controller;

import cn.yunhe.service.ChildTypeService;
import cn.yunhe.service.GrandTypeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/UpdateGrandSonTypeServlet")
public class UpdateGrandSonTypeServlet  extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String chtypeid=request.getParameter("chtypeid");
        request.setAttribute("chtypeid",chtypeid);
        System.out.println("中类别的编号"+chtypeid);
        int  gtypeid=Integer.parseInt(request.getParameter("gtypeid"));
        String gtypename =request.getParameter("gtypename");
        GrandTypeService grandTypeService=new GrandTypeService();
        boolean flag= grandTypeService.updateGrandSonType(gtypename,gtypeid);
        if(flag){
            request.getRequestDispatcher("ShowGrandSonServlet").forward(request,response);
        }else{
            response.sendRedirect("false.html");
        }
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
